package com.clouddancer.controller;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ai")
public class ChatController {

    @Autowired
    private ChatLanguageModel chatModel;  // 修正变量命名和空格

    @GetMapping("/chat") // 更规范的GET请求注解（原图符号错误）
    public String chat(
            @RequestParam(defaultValue = "你是谁") String message  // 参数默认值
    ) {
        String response = chatModel.chat(message);  // 调用模型并返回结果
        return response;
    }
}